<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%--
  Created by IntelliJ IDEA.
  User: Lemon
  Date: 2020/6/18
  Time: 9:25
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>

<head>
    <title>处理服务</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/layui/css/layui.css">
    <style type="text/css">
        .layui-form-item{
            margin-top: 16px;
            margin-left:60px;
            font-size: 16px;
        }
    </style>
</head>
<body>
<!-- 编辑添加框 -->
<!-- form外面要有一个div-->
<form class="layui-form" lay-filter="myform">
    <div style="width: 99.8%;height:35px;line-height:35px;border: 1px #f1f1f1 solid;background-color: #f5f5f5;" ><span style="margin-left: 28px;">处理信息</span></div>

    <input type="hidden" name="id" value=""/>

    <div class="layui-form-item">
        <label class="layui-form-label">客户：</label>
        <div class="layui-input-inline" style="width: 320px">
            <input type="hidden" name="customerId" value="" />
            <input type="text" name="customerName" class="layui-input" readonly="readonly" value="${serviceSelf.customer_name}" />
        </div>
    </div>
    <hr>
    <div class="layui-form-item">
        <label class="layui-form-label">处理时间：</label>
        <div class="layui-input-inline" style="width: 320px;">
            <input type="text" name="handler_time" placeholder="请选择时间" class="layui-input" id="handler_time_div" value="<fmt:formatDate value="${serviceSelf.handler_time}" pattern="yyyy-MM-dd HH:mm:ss"/>">
        </div>
    </div>
    <hr >
    <div class="layui-form-item">
        <label class="layui-form-label">处理过程：</label>
        <div class="layui-input-block" style="width: 730px">
            <textarea class="layui-textarea" id="handle_content" name="handle_content">${serviceSelf.handle_content}</textarea>
        </div>
    </div>
    <hr >
    <div class="layui-form-item">
        <label class="layui-form-label">处理结果：</label>
        <div class="layui-input-block" style="width: 730px;">
            <textarea name="handle_result" style="height:150px;" placeholder="请输入处理的结果" class="layui-textarea">${serviceSelf.handle_result}</textarea>
        </div>
    </div>
    <hr>
    <div class="layui-form-item">
        <label class="layui-form-label" >更新状态：</label>
        <div class="layui-input-inline" style="width: 320px">
            <select name="status">
                <option value="未处理">未处理</option>
                <option value="处理中">处理中</option>
                <option value="已处理">已处理</option>
                <option value="已归档">已归档</option>
            </select>
        </div>
    </div>
    <hr>
    <div class="layui-form-item">
        <label class="layui-form-label" style="width: 100px;margin-left: -20px;">客户满意度：</label>
        <div class="layui-input-inline" style="width: 320px">
            <select name="degree">
                <option>☆</option>
                <option>☆☆</option>
                <option>☆☆☆</option>
                <option>☆☆☆☆</option>
                <option>☆☆☆☆☆</option>
            </select>
        </div>
    </div>
    <input type="hidden" name="id" value="">
    <div class="layui-form-item" style="margin-top: 30px;">
        <div class="layui-input-block">
            <button type="reset" class="layui-btn layui-btn-warm" style="margin-left: 250px;">重置</button>
            <button type="button" name="handleService" lay-submit lay-filter="handleService" class="layui-btn">保存</button>
        </div>
    </div>
</form>
</body>
<%--引入js--%>
<script src="${pageContext.request.contextPath}/static/layui/layui.js"></script>
<script>
    //layui引入特定模块的方式
    layui.use(['layer', 'form','jquery','laydate','layedit'], function(){
        var layer = layui.layer//layer 弹窗对象
            ,form = layui.form;//表单对象
        var $=layui.$;//jquery对象
        var laydate = layui.laydate;
        var layedit = layui.layedit;

        laydate.render({
            elem : '#handler_time_div',
            type : 'datetime'
        });

        layedit.set({
            uploadImage: {//图片上传的接口
                url: '${pageContext.request.contextPath}/service/uploadImg' //接口url
                ,type: 'post' //默认post
            },
            height:200
        });

        var index = layedit.build('handle_content'); //建立编辑器

        //表单提交监听
        form.on("submit(handleService)",function (data) {
            //将内容同步到textarea
            layedit.sync(index);
            //获取富文本内容
            var text=layedit.getText(index);
            data.field.content=text;
            console.log(data.field);
            //获取表单数据项
            console.log($("form").serialize());
            console.log(${serviceSelf.id});
            //发起异步请求，新增 data.field 表单数据
            $.post("${pageContext.request.contextPath}/service/handleService?id="+${serviceSelf.id},$("form").serialize(),function (result) {
                if (result.code==0){
                    layer.msg("新增成功");
                    //刷新父窗口的表格 parent 父窗口对象
                    parent.layui.table.reload("serviceTable",{
                        page:{
                            curr:1
                        }
                    });
                    //关闭本窗口
                    //当你在iframe页面关闭自身时
                    var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                    parent.layer.close(index); //再执行关闭
                }
                else {
                    layer.alert("新增失败");
                }
            },"json");
            return false;//阻止表单跳转。如果需要表单跳转，去掉这段即可。
        })
    });
</script>
</html>
